package org.esgi.model.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.esgi.model.interfaces.IHistory;
import org.esgi.model.interfaces.IQuestion;

public class History implements IHistory
{
	private String id_;
	private String formId_;
	private String formName_;
	private Date startingDate_;
	private List<IQuestion> questions_;
	
	@Override
	public String getId() 
	{
		return this.id_;
	}

	@Override
	public void setId(String anId)
	{
		this.id_ = anId;			
	}

	@Override
	public String getFormId() 
	{
		return this.formId_;
	}

	@Override
	public void setFormId(String anId) 
	{
		this.formId_ = anId;
	}

	@Override
	public String getFormName()
	{
		return this.formName_;
	}
	
	@Override
	public void setFormName(String aName)
	{
		this.formName_ = aName;
	}
	
	@Override
	public void setStartingDate(Date date)
	{
		this.startingDate_ = date;
	}
	
	@Override
	public Date getStartingDate()
	{
		return this.startingDate_;
	}

	@Override
	public List<IQuestion> getQuestions()
	{
		return this.questions_;
	}

	@Override
	public void setQuestions(List<IQuestion> questions) 
	{
		this.questions_ = questions;
	}
	
	@Override
	public void addQuestion(IQuestion question)
	{
		List<IQuestion> questions = this.getQuestions();
		if(questions == null)
		{
			this.setQuestions(new ArrayList<IQuestion>());
			questions = this.getQuestions();
		}
		questions.add(question);	
	}
	
	@Override
	public void removeLastQuestion()
	{
		List<IQuestion> questions = this.getQuestions();
		if(questions != null)
		{
			int size = questions.size();
			if(size > 0)
				questions.remove(size-1);
		}
	}

	@Override
	public String toString() {
		return "History [id_=" + id_ + ", formId_=" + formId_
				+ ", startingDate_=" + startingDate_ + ", questions_="
				+ questions_ + "]";
	}
	
}
